package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;


@EqualsAndHashCode(callSuper = true)
@Data
public class LoginException extends RuntimeException {
    private Integer code; // 错误码（如1001：账号不存在，1002：密码错误）

    public LoginException(ResultCodeEnum code, String message) {
        super(message);
        this.code = code.getCode();
    }

    public LoginException(String message) {
        this(ResultCodeEnum.APP_LOGIN_ERROR, message); // 默认500：服务器错误
    }

    public LoginException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

}